package com.chinasoft.maysham.manager.response;

import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;

import java.util.Collections;
import java.util.List;

public class PageResult<T> extends PageImpl<T> {

    private List<T> data;

    private long page;

    private long totalCount;

    public PageResult(List<T> content, Pageable pageable, long total) {
        super(content, pageable, total);
        this.data = content;
        this.page = getNumber();
        this.totalCount = getTotalElements();
    }

    public PageResult(List<T> content) {
        super(content);
        this.data = content;
        this.page = getNumber();
        this.totalCount = getTotalElements();
    }

    public PageResult() {
        super(Collections.emptyList());
        this.data = Collections.emptyList();
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public long getPage() {
        return page;
    }

    public void setPage(long page) {
        this.page = page;
    }

    public long getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(long totalCount) {
        this.totalCount = totalCount;
    }
}
